package com.hys.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 真或者假 用 true 或者 false 表示
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum TrueOrFalseEnum {

    TRUE(1, "是"),
    FALSE(0, "否");
    private Integer code;
    private String desc;

    public static boolean isTrue( Integer code){
        return TRUE.code.equals(code);
    }

    public static boolean isFalse( Integer code){
        return FALSE.code.equals(code);
    }

    public static Integer getFalseCode(){
        return FALSE.code;
    }

    public static Integer getTrueCode(){
        return TRUE.code;
    }

    public static Boolean getByCode( Integer code){

        if(isTrue(code)){
            return true;
        }
        if(isFalse(code)){
            return false;
        }
        return null;
    }


}
